/* ES5类 */
{
    function Hunman(name) {
        this.name = name;
        this.age = 0;
    }

    Hunman.prototype.playGame = function (gameName) {
        console.log("Es5 I am play " + gameName);
    }

    Hunman.prototype.reset = function () {
        this.age = 0;
    }

    let xiaoming = new Hunman('xiaoming');
    xiaoming.playGame('Persona4');
}



/* ES6 */
/* 类的定义和实例生成: 成员都在构造函数定义,方法可以不写function */
{
    class Parent {
        constructor(name = 'mukewang') {
            this.name = name;
        }
        playGame(gameName) {
            console.log('I am playing ' + gameName);
        }
    }
    let v_parent = new Parent('v');
    console.log('构造函数和实例', v_parent);
    v_parent.playGame('Persona5');
}


/* 继承extends */
{
    class Parent {
        constructor(name = 'mukewang') {
            this.name = name;
        }
    }
    class Child extends Parent {
    }
    console.log('继承', new Child());
}


/* super */
{
    class Parent {
        constructor(name = 'mukewang') {
            this.name = name;
        }
    }
    class Child extends Parent {
        constructor(name = 'child') {
            super(name);
            this.type = 'child';
        }
    }
    console.log('继承传递参数', new Child('hello'));
}


/* getter setter */
{
    class Parent {
        constructor(name = 'mukewang') {
            this.name = name;
        }

        get longName() {
            return 'mk' + this.name
        }

        set longName(value) {
            this.name = value;
        }
    }
    let v = new Parent();
    console.log('getter', v.longName);
    v.longName = 'hello';
    console.log('setter', v.longName);
}


/* static静态方法 */
{
    class Parent {
        constructor(name = 'mukewang') {
            this.name = name;
        }
        static tell() {
            console.log('tell');
        }
    }
    Parent.tell();
}


/* 静态属性 */
{
    class Parent {
        constructor(name = 'mukewang') {
            this.name = name;
        }

        static tell() {
            console.log('tell');
        }
    }

    Parent.type = 'test';
    console.log('静态属性', Parent.type);
}